/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Core.Util;
using Neo.Framework;

#endregion

#region TitleBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Title : EntityObject
{
	/// <summary>
	/// A collection of TitleAuthor objects referencing this instance.</summary>
	/// <remarks> Objects referencing this instance.</remarks>
	public readonly ObjectRelation<TitleAuthor> TitleAuthors;
       
	internal Title(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
		TitleAuthors = new ObjectRelation<TitleAuthor>(this, "TitleAuthors");
	}
	
	/// <summary>
	/// Property TitleId -  Book id </summary>
	/// <remarks> Database Path: pubs.titles.title_id.</remarks>
	/// <value> System.String. </value>
	public virtual System.String TitleId
	{
		get { return Row["title_id"] as System.String; }
		set { Row["title_id"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property TheTitle -  Book title </summary>
	/// <remarks> Database Path: pubs.titles.title.</remarks>
	/// <value> System.String. </value>
	public virtual System.String TheTitle
	{
		get { return Row["title"] as System.String; }
		set { Row["title"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Type -  Book type </summary>
	/// <remarks> Database Path: pubs.titles.type.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Type
	{
		get { return Row["type"] as System.String; }
		set { Row["type"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Price -  Book price </summary>
	/// <remarks> Database Path: pubs.titles.price.</remarks>
	/// <value> System.Decimal. </value>
	public virtual System.Decimal? Price
	{
		get { object v = Row["price"]; return (System.Decimal?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["price"] = value; else Row["price"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property Advance -  Advance </summary>
	/// <remarks> Database Path: pubs.titles.advance.</remarks>
	/// <value> System.Decimal. </value>
	public virtual System.Decimal? Advance
	{
		get { object v = Row["advance"]; return (System.Decimal?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["advance"] = value; else Row["advance"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property Royalty -  Royalty? </summary>
	/// <remarks> Database Path: pubs.titles.royalty.</remarks>
	/// <value> System.Int32. </value>
	public virtual System.Int32? Royalty
	{
		get { object v = Row["royalty"]; return (System.Int32?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["royalty"] = value; else Row["royalty"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property YtdSales -  Sales this year </summary>
	/// <remarks> Database Path: pubs.titles.ytd_sales.</remarks>
	/// <value> System.Int32. </value>
	public virtual System.Int32? YtdSales
	{
		get { object v = Row["ytd_sales"]; return (System.Int32?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["ytd_sales"] = value; else Row["ytd_sales"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property Notes -  Notes (free text) </summary>
	/// <remarks> Database Path: pubs.titles.notes.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Notes
	{
		get { return Row["notes"] as System.String; }
		set { Row["notes"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property PublicationDate -  Publication date </summary>
	/// <remarks> Database Path: pubs.titles.pubdate.</remarks>
	/// <value> System.DateTime. </value>
	public virtual System.DateTime? PublicationDate
	{
		get { object v = Row["pubdate"]; return (System.DateTime?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["pubdate"] = value; else Row["pubdate"] = DBNull.Value; }
	}    


	/// <summary>
	/// Property Publisher - gets or sets the Publisher object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Property Publisher - gets or sets the Publisher object with a one-to-one relationship to this instance.</remarks>
	/// <value> Publisher. </value>
	public virtual Publisher Publisher
	{
		get { object fk = Row["pub_id"]; return (fk == DBNull.Value) ? null : (Publisher)GetRelatedObject("publishers", fk); }
		set { SetRelatedObject(value, "pub_id", "pub_id" ); }
	}

	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "TitleId") 
			return TitleId;
		if(propName == "TheTitle") 
			return TheTitle;
		if(propName == "Type") 
			return Type;
		if(propName == "Price") 
			return Price;
		if(propName == "Advance") 
			return Advance;
		if(propName == "Royalty") 
			return Royalty;
		if(propName == "YtdSales") 
			return YtdSales;
		if(propName == "Notes") 
			return Notes;
		if(propName == "PublicationDate") 
			return PublicationDate;
		if(propName == "Publisher") 
			return Publisher;

		return base.GetProperty(propName);
	}


    /// <summary>
    /// Ensures related tables are loaded into memory for a cascaded delete.</summary>
    /// <remarks> Deletes related tables entries when cascade is specified.</remarks>
    public override void Delete() 
    {
        TitleAuthors.Touch();
        while (TitleAuthors.Count > 0)
        {
            TitleAuthors[0].Delete();
        }
        base.Delete();
    }
	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(TitleSurrogate surrogate)
	{
		TheTitle = surrogate.TheTitle;
		Type = surrogate.Type;
		Price = surrogate.Price;
		Advance = surrogate.Advance;
		Royalty = surrogate.Royalty;
		YtdSales = surrogate.YtdSales;
		Notes = surrogate.Notes;
		PublicationDate = surrogate.PublicationDate;
	}
}

#endregion

#region TitleTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Title operations. </remarks>
public class TitleTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public TitleTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property TitleId -  Book id </summary>
	/// <remarks> Database Path: pubs.titles.title_id.</remarks>
	/// <value> System.String. </value>
	public System.String TitleId
	{
		get { return (System.String)QueryValues["TitleId"]; }
		set { QueryValues["TitleId"] = value; }
	}

	/// <summary>
	/// Property TheTitle -  Book title </summary>
	/// <remarks> Database Path: pubs.titles.title.</remarks>
	/// <value> System.String. </value>
	public System.String TheTitle
	{
		get { return (System.String)QueryValues["TheTitle"]; }
		set { QueryValues["TheTitle"] = value; }
	}

	/// <summary>
	/// Property Type -  Book type </summary>
	/// <remarks> Database Path: pubs.titles.type.</remarks>
	/// <value> System.String. </value>
	public System.String Type
	{
		get { return (System.String)QueryValues["Type"]; }
		set { QueryValues["Type"] = value; }
	}

	/// <summary>
	/// Property Price -  Book price </summary>
	/// <remarks> Database Path: pubs.titles.price.</remarks>
	/// <value> System.Decimal. </value>
	public System.Decimal Price
	{
		get { return (System.Decimal)QueryValues["Price"]; }
		set { QueryValues["Price"] = value; }
	}

	/// <summary>
	/// Property Advance -  Advance </summary>
	/// <remarks> Database Path: pubs.titles.advance.</remarks>
	/// <value> System.Decimal. </value>
	public System.Decimal Advance
	{
		get { return (System.Decimal)QueryValues["Advance"]; }
		set { QueryValues["Advance"] = value; }
	}

	/// <summary>
	/// Property Royalty -  Royalty? </summary>
	/// <remarks> Database Path: pubs.titles.royalty.</remarks>
	/// <value> System.Int32. </value>
	public System.Int32 Royalty
	{
		get { return (System.Int32)QueryValues["Royalty"]; }
		set { QueryValues["Royalty"] = value; }
	}

	/// <summary>
	/// Property YtdSales -  Sales this year </summary>
	/// <remarks> Database Path: pubs.titles.ytd_sales.</remarks>
	/// <value> System.Int32. </value>
	public System.Int32 YtdSales
	{
		get { return (System.Int32)QueryValues["YtdSales"]; }
		set { QueryValues["YtdSales"] = value; }
	}

	/// <summary>
	/// Property Notes -  Notes (free text) </summary>
	/// <remarks> Database Path: pubs.titles.notes.</remarks>
	/// <value> System.String. </value>
	public System.String Notes
	{
		get { return (System.String)QueryValues["Notes"]; }
		set { QueryValues["Notes"] = value; }
	}

	/// <summary>
	/// Property PublicationDate -  Publication date </summary>
	/// <remarks> Database Path: pubs.titles.pubdate.</remarks>
	/// <value> System.DateTime. </value>
	public System.DateTime PublicationDate
	{
		get { return (System.DateTime)QueryValues["PublicationDate"]; }
		set { QueryValues["PublicationDate"] = value; }
	}

	/// <summary>
	/// Property Publisher - gets or sets the Publisher object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Gets or sets the Publisher object.</remarks>
	/// <value> Publisher. </value>
	public Publisher Publisher
	{
		get { return (Publisher)QueryValues["Publisher"]; }
		set { QueryValues["Publisher"] = value; }
	}

               
}

#endregion

#region TitleFactory

/// <summary>
/// Factory class for the creation of Title objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class TitleFactory : Neo.Framework.GenericObjectFactory<Title>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Title objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public TitleFactory(ObjectContext context) : base(context, typeof(Title))
	{
	}

	/// <summary>
	/// Create new Title object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 1.</remarks>
	/// <param name="arg0">Book id.</param>
	/// <returns> Title </returns>
	public Title CreateObject(System.String arg0)
	{
		return (Title)base.CreateObject(new object[] { arg0 } );
	}
	

	/// <summary>
	/// Find a specified Title object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">Book id.</param>
	/// <returns> Title </returns>
	public Title FindObject(System.String arg0)
	{
		return (Title)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Title object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">Book id.</param>
	///<returns> Title </returns>
	public Title FindObjectByPK( System.String arg0 )
	{
		return (Title) base.FindObject( new object[] {  arg0 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the Title object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> TitleTemplate </returns>
	public TitleTemplate GetQueryTemplate()
	{
		return new TitleTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Title. </returns>
	public override Title FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Title> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Title</returns>
    public override Title FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Title> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region TitleEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Title DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class TitleMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "title_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "title_id", "title", "type", "pub_id", "price", "advance", "royalty", "ytd_sales", "notes", "pubdate" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "TitleId", "TheTitle", "Type", "PubId", "Price", "Advance", "Royalty", "YtdSales", "Notes", "PublicationDate" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { "Publisher", "TitleAuthors" };

    private Type concreteObjectType = typeof(Title);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Title); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "titles"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(2);
  		infos.Add("Publisher", new RelationInfo(Factory, typeof(Publisher), typeof(Title), "pub_id", "pub_id"));
 		infos.Add("TitleAuthors", new RelationInfo(Factory, typeof(Title), typeof(TitleAuthor), "title_id", "title_id"));
		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of Title.</summary>
	/// <remarks>Create new Title.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Title(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("title_id", typeof(System.String));
		c.Unique = true;
		c = table.Columns.Add("title", typeof(System.String));
		c = table.Columns.Add("type", typeof(System.String));
		c = table.Columns.Add("pub_id", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("price", typeof(System.Decimal));
		c.AllowDBNull = true;
		c = table.Columns.Add("advance", typeof(System.Decimal));
		c.AllowDBNull = true;
		c = table.Columns.Add("royalty", typeof(System.Int32));
		c.AllowDBNull = true;
		c = table.Columns.Add("ytd_sales", typeof(System.Int32));
		c.AllowDBNull = true;
		c = table.Columns.Add("notes", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("pubdate", typeof(System.DateTime));
		table.PrimaryKey = new DataColumn[] { table.Columns["title_id"] };
	}
	
	/// <summary>Generates the dataset relationships.</summary>
	/// <remarks>Dataset Relationships.</remarks>
	/// <param name="table">DataTable.</param>
	protected override void WriteRelations(DataTable table)
	{
		DataRelation r;
		
		if(table.DataSet.Relations["publishers*titles.pub_id"] == null)
		{
			r = table.DataSet.Relations.Add("publishers*titles.pub_id", 
					table.DataSet.Tables["publishers"].Columns["pub_id"],
					table.DataSet.Tables["titles"].Columns["pub_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.SetNull;
		}
 		if(table.DataSet.Relations["titles*titleauthor.title_id"] == null)
		{
			r = table.DataSet.Relations.Add("titles*titleauthor.title_id", 
					table.DataSet.Tables["titles"].Columns["title_id"],
					table.DataSet.Tables["titleauthor"].Columns["title_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.Cascade;
		}
	}
}

#endregion

#region TitleSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.titles.</para>
/// </remarks>
[Serializable]
public abstract class TitleSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public TitleSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="TitleSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public TitleSurrogateBase(Title entity)
    {
		TitleId = entity.TitleId;
		TheTitle = entity.TheTitle;
		Type = entity.Type;
		Price = entity.Price;
		Advance = entity.Advance;
		Royalty = entity.Royalty;
		YtdSales = entity.YtdSales;
		Notes = entity.Notes;
		PublicationDate = entity.PublicationDate;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Title entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.TheTitle = TheTitle;
			entity.Type = Type;
			entity.Price = Price;
			entity.Advance = Advance;
			entity.Royalty = Royalty;
			entity.YtdSales = YtdSales;
			entity.Notes = Notes;
			entity.PublicationDate = PublicationDate;
		}
		else
		{
			if (_thetitleHasBeenUpdated)
			{
				entity.TheTitle = TheTitle;
			}
			if (_typeHasBeenUpdated)
			{
				entity.Type = Type;
			}
			if (_priceHasBeenUpdated)
			{
				entity.Price = Price;
			}
			if (_advanceHasBeenUpdated)
			{
				entity.Advance = Advance;
			}
			if (_royaltyHasBeenUpdated)
			{
				entity.Royalty = Royalty;
			}
			if (_ytdsalesHasBeenUpdated)
			{
				entity.YtdSales = YtdSales;
			}
			if (_notesHasBeenUpdated)
			{
				entity.Notes = Notes;
			}
			if (_publicationdateHasBeenUpdated)
			{
				entity.PublicationDate = PublicationDate;
			}
		}
    }
    
    /// <summary>
    /// Property TitleAuthors </summary>
    /// <remarks> </remarks>
    /// <value> System.Collections.ArrayList </value>
    public System.Collections.ArrayList TitleAuthors
    {
    	get {return _titleauthors;}
    	set {_titleauthors = value;}
    }
		
	private System.Collections.ArrayList _titleauthors;
	
    /// <summary>
    /// Property TitleId -  Book id </summary>
    /// <remarks> Database Path: pubs.titles.title_id.</remarks>
    /// <value> System.String. </value>
    public System.String TitleId
    {
    	get {return _titleid;}
		set {_titleid = value;}
    }

	private System.String _titleid;
	
    /// <summary>
    /// Property TheTitle -  Book title </summary>
    /// <remarks> Database Path: pubs.titles.title.</remarks>
    /// <value> System.String. </value>
    public System.String TheTitle
    {
    	get {return _thetitle;}
    	set {_thetitle = value; _thetitleHasBeenUpdated = true;}
    }

	private System.String _thetitle;
    private bool _thetitleHasBeenUpdated;
	
    /// <summary>
    /// Property Type -  Book type </summary>
    /// <remarks> Database Path: pubs.titles.type.</remarks>
    /// <value> System.String. </value>
    public System.String Type
    {
    	get {return _type;}
    	set {_type = value; _typeHasBeenUpdated = true;}
    }

	private System.String _type;
    private bool _typeHasBeenUpdated;
	
	/// <summary>
    /// Property Price -  Book price </summary>
    /// <remarks> Database Path: pubs.titles.price.</remarks>
    /// <value> System.Decimal. </value>
    public System.Decimal? Price
    {
    	get {return _price;}
    	set {_price = value; _priceHasBeenUpdated = true;}
    }

	private System.Decimal? _price;
    private bool _priceHasBeenUpdated;
	
	/// <summary>
    /// Property Advance -  Advance </summary>
    /// <remarks> Database Path: pubs.titles.advance.</remarks>
    /// <value> System.Decimal. </value>
    public System.Decimal? Advance
    {
    	get {return _advance;}
    	set {_advance = value; _advanceHasBeenUpdated = true;}
    }

	private System.Decimal? _advance;
    private bool _advanceHasBeenUpdated;
	
	/// <summary>
    /// Property Royalty -  Royalty? </summary>
    /// <remarks> Database Path: pubs.titles.royalty.</remarks>
    /// <value> System.Int32. </value>
    public System.Int32? Royalty
    {
    	get {return _royalty;}
    	set {_royalty = value; _royaltyHasBeenUpdated = true;}
    }

	private System.Int32? _royalty;
    private bool _royaltyHasBeenUpdated;
	
	/// <summary>
    /// Property YtdSales -  Sales this year </summary>
    /// <remarks> Database Path: pubs.titles.ytd_sales.</remarks>
    /// <value> System.Int32. </value>
    public System.Int32? YtdSales
    {
    	get {return _ytdsales;}
    	set {_ytdsales = value; _ytdsalesHasBeenUpdated = true;}
    }

	private System.Int32? _ytdsales;
    private bool _ytdsalesHasBeenUpdated;
	
    /// <summary>
    /// Property Notes -  Notes (free text) </summary>
    /// <remarks> Database Path: pubs.titles.notes.</remarks>
    /// <value> System.String. </value>
    public System.String Notes
    {
    	get {return _notes;}
    	set {_notes = value; _notesHasBeenUpdated = true;}
    }

	private System.String _notes;
    private bool _notesHasBeenUpdated;
	
	/// <summary>
    /// Property PublicationDate -  Publication date </summary>
    /// <remarks> Database Path: pubs.titles.pubdate.</remarks>
    /// <value> System.DateTime. </value>
    public System.DateTime? PublicationDate
    {
    	get {return _publicationdate;}
    	set {_publicationdate = value; _publicationdateHasBeenUpdated = true;}
    }

	private System.DateTime? _publicationdate;
    private bool _publicationdateHasBeenUpdated;
	
    /// <summary>
    /// Property Publisher - gets or sets the Publisher object with a one-to-one relationship to this instance.</summary>
    /// <remarks> Property Publisher - gets or sets the Publisher object with a one-to-one relationship to this instance.</remarks>
    /// <value> Publisher. </value>
    public PublisherSurrogate Publisher
    {
    	get {return _publisher;}
    	set {_publisher = value;}
    }

	private PublisherSurrogate _publisher;
		

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(TitleTemplate emptyTemplate)
    {

    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Core.Util;
using Neo.Framework;

#endregion

#region PublisherBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Publisher : EntityObject
{
	/// <summary>
	/// A collection of Title objects referencing this instance.</summary>
	/// <remarks> Objects referencing this instance.</remarks>
	public readonly ObjectRelation<Title> Titles;
       
	internal Publisher(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
		Titles = new ObjectRelation<Title>(this, "Titles");
	}
	
	/// <summary>
	/// Property PubId -  Publisher id </summary>
	/// <remarks> Database Path: pubs.publishers.pub_id.</remarks>
	/// <value> System.String. </value>
	public virtual System.String PubId
	{
		get { return Row["pub_id"] as System.String; }
		set { Row["pub_id"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Name -  Publisher name </summary>
	/// <remarks> Database Path: pubs.publishers.pub_name.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Name
	{
		get { return Row["pub_name"] as System.String; }
		set { Row["pub_name"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property City -  Publisher city </summary>
	/// <remarks> Database Path: pubs.publishers.city.</remarks>
	/// <value> System.String. </value>
	public virtual System.String City
	{
		get { return Row["city"] as System.String; }
		set { Row["city"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property State -  Publisher state code </summary>
	/// <remarks> Database Path: pubs.publishers.state.</remarks>
	/// <value> System.String. </value>
	public virtual System.String State
	{
		get { return Row["state"] as System.String; }
		set { Row["state"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Country -  Publisher country </summary>
	/// <remarks> Database Path: pubs.publishers.country.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Country
	{
		get { return Row["country"] as System.String; }
		set { Row["country"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    


	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "PubId") 
			return PubId;
		if(propName == "Name") 
			return Name;
		if(propName == "City") 
			return City;
		if(propName == "State") 
			return State;
		if(propName == "Country") 
			return Country;

		return base.GetProperty(propName);
	}


    /// <summary>
    /// Ensures related tables are loaded into memory for a cascaded delete.</summary>
    /// <remarks> Deletes related tables entries when cascade is specified.</remarks>
    public override void Delete() 
    {
        base.Delete();
    }
	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(PublisherSurrogate surrogate)
	{
		Name = surrogate.Name;
		City = surrogate.City;
		State = surrogate.State;
		Country = surrogate.Country;
	}
}

#endregion

#region PublisherTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Publisher operations. </remarks>
public class PublisherTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public PublisherTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property PubId -  Publisher id </summary>
	/// <remarks> Database Path: pubs.publishers.pub_id.</remarks>
	/// <value> System.String. </value>
	public System.String PubId
	{
		get { return (System.String)QueryValues["PubId"]; }
		set { QueryValues["PubId"] = value; }
	}

	/// <summary>
	/// Property Name -  Publisher name </summary>
	/// <remarks> Database Path: pubs.publishers.pub_name.</remarks>
	/// <value> System.String. </value>
	public System.String Name
	{
		get { return (System.String)QueryValues["Name"]; }
		set { QueryValues["Name"] = value; }
	}

	/// <summary>
	/// Property City -  Publisher city </summary>
	/// <remarks> Database Path: pubs.publishers.city.</remarks>
	/// <value> System.String. </value>
	public System.String City
	{
		get { return (System.String)QueryValues["City"]; }
		set { QueryValues["City"] = value; }
	}

	/// <summary>
	/// Property State -  Publisher state code </summary>
	/// <remarks> Database Path: pubs.publishers.state.</remarks>
	/// <value> System.String. </value>
	public System.String State
	{
		get { return (System.String)QueryValues["State"]; }
		set { QueryValues["State"] = value; }
	}

	/// <summary>
	/// Property Country -  Publisher country </summary>
	/// <remarks> Database Path: pubs.publishers.country.</remarks>
	/// <value> System.String. </value>
	public System.String Country
	{
		get { return (System.String)QueryValues["Country"]; }
		set { QueryValues["Country"] = value; }
	}

               
}

#endregion

#region PublisherFactory

/// <summary>
/// Factory class for the creation of Publisher objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class PublisherFactory : Neo.Framework.GenericObjectFactory<Publisher>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Publisher objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public PublisherFactory(ObjectContext context) : base(context, typeof(Publisher))
	{
	}

	/// <summary>
	/// Create new Publisher object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 1.</remarks>
	/// <param name="arg0">Publisher id.</param>
	/// <returns> Publisher </returns>
	public Publisher CreateObject(System.String arg0)
	{
		return (Publisher)base.CreateObject(new object[] { arg0 } );
	}
	

	/// <summary>
	/// Find a specified Publisher object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">Publisher id.</param>
	/// <returns> Publisher </returns>
	public Publisher FindObject(System.String arg0)
	{
		return (Publisher)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Publisher object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">Publisher id.</param>
	///<returns> Publisher </returns>
	public Publisher FindObjectByPK( System.String arg0 )
	{
		return (Publisher) base.FindObject( new object[] {  arg0 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the Publisher object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> PublisherTemplate </returns>
	public PublisherTemplate GetQueryTemplate()
	{
		return new PublisherTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Publisher. </returns>
	public override Publisher FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Publisher> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Publisher</returns>
    public override Publisher FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Publisher> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region PublisherEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Publisher DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class PublisherMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "pub_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "pub_id", "pub_name", "city", "state", "country" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "PubId", "Name", "City", "State", "Country" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { "Titles" };

    private Type concreteObjectType = typeof(Publisher);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Publisher); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "publishers"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(1);
  		infos.Add("Titles", new RelationInfo(Factory, typeof(Publisher), typeof(Title), "pub_id", "pub_id"));
		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of Publisher.</summary>
	/// <remarks>Create new Publisher.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Publisher(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("pub_id", typeof(System.String));
		c.Unique = true;
		c = table.Columns.Add("pub_name", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("city", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("state", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("country", typeof(System.String));
		c.AllowDBNull = true;
		table.PrimaryKey = new DataColumn[] { table.Columns["pub_id"] };
	}
	
	/// <summary>Generates the dataset relationships.</summary>
	/// <remarks>Dataset Relationships.</remarks>
	/// <param name="table">DataTable.</param>
	protected override void WriteRelations(DataTable table)
	{
		DataRelation r;
		
 		if(table.DataSet.Relations["publishers*titles.pub_id"] == null)
		{
			r = table.DataSet.Relations.Add("publishers*titles.pub_id", 
					table.DataSet.Tables["publishers"].Columns["pub_id"],
					table.DataSet.Tables["titles"].Columns["pub_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.SetNull;
		}
	}
}

#endregion

#region PublisherSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.publishers.</para>
/// </remarks>
[Serializable]
public abstract class PublisherSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public PublisherSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="PublisherSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public PublisherSurrogateBase(Publisher entity)
    {
		PubId = entity.PubId;
		Name = entity.Name;
		City = entity.City;
		State = entity.State;
		Country = entity.Country;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Publisher entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.Name = Name;
			entity.City = City;
			entity.State = State;
			entity.Country = Country;
		}
		else
		{
			if (_nameHasBeenUpdated)
			{
				entity.Name = Name;
			}
			if (_cityHasBeenUpdated)
			{
				entity.City = City;
			}
			if (_stateHasBeenUpdated)
			{
				entity.State = State;
			}
			if (_countryHasBeenUpdated)
			{
				entity.Country = Country;
			}
		}
    }
    
    /// <summary>
    /// Property Titles </summary>
    /// <remarks> </remarks>
    /// <value> System.Collections.ArrayList </value>
    public System.Collections.ArrayList Titles
    {
    	get {return _titles;}
    	set {_titles = value;}
    }
		
	private System.Collections.ArrayList _titles;
	
    /// <summary>
    /// Property PubId -  Publisher id </summary>
    /// <remarks> Database Path: pubs.publishers.pub_id.</remarks>
    /// <value> System.String. </value>
    public System.String PubId
    {
    	get {return _pubid;}
		set {_pubid = value;}
    }

	private System.String _pubid;
	
    /// <summary>
    /// Property Name -  Publisher name </summary>
    /// <remarks> Database Path: pubs.publishers.pub_name.</remarks>
    /// <value> System.String. </value>
    public System.String Name
    {
    	get {return _name;}
    	set {_name = value; _nameHasBeenUpdated = true;}
    }

	private System.String _name;
    private bool _nameHasBeenUpdated;
	
    /// <summary>
    /// Property City -  Publisher city </summary>
    /// <remarks> Database Path: pubs.publishers.city.</remarks>
    /// <value> System.String. </value>
    public System.String City
    {
    	get {return _city;}
    	set {_city = value; _cityHasBeenUpdated = true;}
    }

	private System.String _city;
    private bool _cityHasBeenUpdated;
	
    /// <summary>
    /// Property State -  Publisher state code </summary>
    /// <remarks> Database Path: pubs.publishers.state.</remarks>
    /// <value> System.String. </value>
    public System.String State
    {
    	get {return _state;}
    	set {_state = value; _stateHasBeenUpdated = true;}
    }

	private System.String _state;
    private bool _stateHasBeenUpdated;
	
    /// <summary>
    /// Property Country -  Publisher country </summary>
    /// <remarks> Database Path: pubs.publishers.country.</remarks>
    /// <value> System.String. </value>
    public System.String Country
    {
    	get {return _country;}
    	set {_country = value; _countryHasBeenUpdated = true;}
    }

	private System.String _country;
    private bool _countryHasBeenUpdated;
	

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(PublisherTemplate emptyTemplate)
    {
    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Core.Util;
using Neo.Framework;

#endregion

#region AuthorBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Author : EntityObject
{
	/// <summary>
	/// A collection of TitleAuthor objects referencing this instance.</summary>
	/// <remarks> Objects referencing this instance.</remarks>
	public readonly ObjectRelation<TitleAuthor> TitleAuthors;
       
	internal Author(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
		TitleAuthors = new ObjectRelation<TitleAuthor>(this, "TitleAuthors");
	}
	
	/// <summary>
	/// Property LastName -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.authors.au_lname.</remarks>
	/// <value> System.String. </value>
	public virtual System.String LastName
	{
		get { return Row["au_lname"] as System.String; }
		set { Row["au_lname"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property FirstName -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.authors.au_fname.</remarks>
	/// <value> System.String. </value>
	public virtual System.String FirstName
	{
		get { return Row["au_fname"] as System.String; }
		set { Row["au_fname"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Phone -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.authors.phone.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Phone
	{
		get { return Row["phone"] as System.String; }
		set { Row["phone"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property ContractSigned -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.authors.contract.</remarks>
	/// <value> System.Boolean. </value>
	public virtual System.Boolean? ContractSigned
	{
		get { object v = Row["contract"]; return (System.Boolean?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["contract"] = value; else Row["contract"] = DBNull.Value; }
	}    


	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "LastName") 
			return LastName;
		if(propName == "FirstName") 
			return FirstName;
		if(propName == "Phone") 
			return Phone;
		if(propName == "ContractSigned") 
			return ContractSigned;

		return base.GetProperty(propName);
	}


    /// <summary>
    /// Ensures related tables are loaded into memory for a cascaded delete.</summary>
    /// <remarks> Deletes related tables entries when cascade is specified.</remarks>
    public override void Delete() 
    {
        TitleAuthors.Touch();
        while (TitleAuthors.Count > 0)
        {
            TitleAuthors[0].Delete();
        }
        base.Delete();
    }
	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(AuthorSurrogate surrogate)
	{
		LastName = surrogate.LastName;
		FirstName = surrogate.FirstName;
		Phone = surrogate.Phone;
		ContractSigned = surrogate.ContractSigned;
	}
}

#endregion

#region AuthorTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Author operations. </remarks>
public class AuthorTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public AuthorTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property LastName -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.authors.au_lname.</remarks>
	/// <value> System.String. </value>
	public System.String LastName
	{
		get { return (System.String)QueryValues["LastName"]; }
		set { QueryValues["LastName"] = value; }
	}

	/// <summary>
	/// Property FirstName -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.authors.au_fname.</remarks>
	/// <value> System.String. </value>
	public System.String FirstName
	{
		get { return (System.String)QueryValues["FirstName"]; }
		set { QueryValues["FirstName"] = value; }
	}

	/// <summary>
	/// Property Phone -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.authors.phone.</remarks>
	/// <value> System.String. </value>
	public System.String Phone
	{
		get { return (System.String)QueryValues["Phone"]; }
		set { QueryValues["Phone"] = value; }
	}

	/// <summary>
	/// Property ContractSigned -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.authors.contract.</remarks>
	/// <value> System.Boolean. </value>
	public System.Boolean ContractSigned
	{
		get { return (System.Boolean)QueryValues["ContractSigned"]; }
		set { QueryValues["ContractSigned"] = value; }
	}

               
}

#endregion

#region AuthorFactory

/// <summary>
/// Factory class for the creation of Author objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class AuthorFactory : Neo.Framework.GenericObjectFactory<Author>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Author objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public AuthorFactory(ObjectContext context) : base(context, typeof(Author))
	{
	}

	/// <summary>
	/// Create new Author object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 1.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Author </returns>
	public Author CreateObject(System.String arg0)
	{
		return (Author)base.CreateObject(new object[] { arg0 } );
	}
	

	/// <summary>
	/// Find a specified Author object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Author </returns>
	public Author FindObject(System.String arg0)
	{
		return (Author)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Author object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">$column.Description.</param>
	///<returns> Author </returns>
	public Author FindObjectByPK( System.String arg0 )
	{
		return (Author) base.FindObject( new object[] {  arg0 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the Author object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> AuthorTemplate </returns>
	public AuthorTemplate GetQueryTemplate()
	{
		return new AuthorTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Author. </returns>
	public override Author FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Author> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Author</returns>
    public override Author FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Author> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region AuthorEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Author DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class AuthorMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "au_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "au_id", "au_lname", "au_fname", "phone", "contract" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "AuId", "LastName", "FirstName", "Phone", "ContractSigned" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { "TitleAuthors" };

    private Type concreteObjectType = typeof(Author);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Author); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "authors"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(1);
  		infos.Add("TitleAuthors", new RelationInfo(Factory, typeof(Author), typeof(TitleAuthor), "au_id", "au_id"));
		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of Author.</summary>
	/// <remarks>Create new Author.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Author(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("au_id", typeof(System.String));
		c.Unique = true;
		c = table.Columns.Add("au_lname", typeof(System.String));
		c = table.Columns.Add("au_fname", typeof(System.String));
		c = table.Columns.Add("phone", typeof(System.String));
		c = table.Columns.Add("contract", typeof(System.Boolean));
		table.PrimaryKey = new DataColumn[] { table.Columns["au_id"] };
	}
	
	/// <summary>Generates the dataset relationships.</summary>
	/// <remarks>Dataset Relationships.</remarks>
	/// <param name="table">DataTable.</param>
	protected override void WriteRelations(DataTable table)
	{
		DataRelation r;
		
 		if(table.DataSet.Relations["authors*titleauthor.au_id"] == null)
		{
			r = table.DataSet.Relations.Add("authors*titleauthor.au_id", 
					table.DataSet.Tables["authors"].Columns["au_id"],
					table.DataSet.Tables["titleauthor"].Columns["au_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.Cascade;
		}
	}
}

#endregion

#region AuthorSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.authors.</para>
/// </remarks>
[Serializable]
public abstract class AuthorSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public AuthorSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="AuthorSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public AuthorSurrogateBase(Author entity)
    {
		LastName = entity.LastName;
		FirstName = entity.FirstName;
		Phone = entity.Phone;
		ContractSigned = entity.ContractSigned;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Author entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.LastName = LastName;
			entity.FirstName = FirstName;
			entity.Phone = Phone;
			entity.ContractSigned = ContractSigned;
		}
		else
		{
			if (_lastnameHasBeenUpdated)
			{
				entity.LastName = LastName;
			}
			if (_firstnameHasBeenUpdated)
			{
				entity.FirstName = FirstName;
			}
			if (_phoneHasBeenUpdated)
			{
				entity.Phone = Phone;
			}
			if (_contractsignedHasBeenUpdated)
			{
				entity.ContractSigned = ContractSigned;
			}
		}
    }
    
    /// <summary>
    /// Property TitleAuthors </summary>
    /// <remarks> </remarks>
    /// <value> System.Collections.ArrayList </value>
    public System.Collections.ArrayList TitleAuthors
    {
    	get {return _titleauthors;}
    	set {_titleauthors = value;}
    }
		
	private System.Collections.ArrayList _titleauthors;
	
    /// <summary>
    /// Property LastName -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.authors.au_lname.</remarks>
    /// <value> System.String. </value>
    public System.String LastName
    {
    	get {return _lastname;}
    	set {_lastname = value; _lastnameHasBeenUpdated = true;}
    }

	private System.String _lastname;
    private bool _lastnameHasBeenUpdated;
	
    /// <summary>
    /// Property FirstName -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.authors.au_fname.</remarks>
    /// <value> System.String. </value>
    public System.String FirstName
    {
    	get {return _firstname;}
    	set {_firstname = value; _firstnameHasBeenUpdated = true;}
    }

	private System.String _firstname;
    private bool _firstnameHasBeenUpdated;
	
    /// <summary>
    /// Property Phone -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.authors.phone.</remarks>
    /// <value> System.String. </value>
    public System.String Phone
    {
    	get {return _phone;}
    	set {_phone = value; _phoneHasBeenUpdated = true;}
    }

	private System.String _phone;
    private bool _phoneHasBeenUpdated;
	
	/// <summary>
    /// Property ContractSigned -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.authors.contract.</remarks>
    /// <value> System.Boolean. </value>
    public System.Boolean? ContractSigned
    {
    	get {return _contractsigned;}
    	set {_contractsigned = value; _contractsignedHasBeenUpdated = true;}
    }

	private System.Boolean? _contractsigned;
    private bool _contractsignedHasBeenUpdated;
	

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(AuthorTemplate emptyTemplate)
    {
    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Core.Util;
using Neo.Framework;

#endregion

#region TitleAuthorBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class TitleAuthor : EntityObject
{
       
	internal TitleAuthor(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
	}
	

	/// <summary>
	/// Property Title - gets or sets the Title object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Property Title - gets or sets the Title object with a one-to-one relationship to this instance.</remarks>
	/// <value> Title. </value>
	public virtual Title Title
	{
		get { object fk = Row["title_id"]; return (fk == DBNull.Value) ? null : (Title)GetRelatedObject("titles", fk); }
		set { SetRelatedObject(value, "title_id", "title_id" ); }
	}

	/// <summary>
	/// Property Author - gets or sets the Author object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Property Author - gets or sets the Author object with a one-to-one relationship to this instance.</remarks>
	/// <value> Author. </value>
	public virtual Author Author
	{
		get { object fk = Row["au_id"]; return (fk == DBNull.Value) ? null : (Author)GetRelatedObject("authors", fk); }
		set { SetRelatedObject(value, "au_id", "au_id" ); }
	}

	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "Title") 
			return Title;
		if(propName == "Author") 
			return Author;

		return base.GetProperty(propName);
	}


	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(TitleAuthorSurrogate surrogate)
	{
	}
}

#endregion

#region TitleAuthorTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for TitleAuthor operations. </remarks>
public class TitleAuthorTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public TitleAuthorTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property Title - gets or sets the Title object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Gets or sets the Title object.</remarks>
	/// <value> Title. </value>
	public Title Title
	{
		get { return (Title)QueryValues["Title"]; }
		set { QueryValues["Title"] = value; }
	}

	/// <summary>
	/// Property Author - gets or sets the Author object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Gets or sets the Author object.</remarks>
	/// <value> Author. </value>
	public Author Author
	{
		get { return (Author)QueryValues["Author"]; }
		set { QueryValues["Author"] = value; }
	}

               
}

#endregion

#region TitleAuthorFactory

/// <summary>
/// Factory class for the creation of TitleAuthor objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class TitleAuthorFactory : Neo.Framework.GenericObjectFactory<TitleAuthor>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new TitleAuthor objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public TitleAuthorFactory(ObjectContext context) : base(context, typeof(TitleAuthor))
	{
	}

	/// <summary>
	/// Create new TitleAuthor object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = True, RelationshipSetsForColumns = 1.</remarks>
	/// <param name="arg0">Author.</param>
	/// <param name="arg1">Title.</param>
	/// <returns> TitleAuthor </returns>
	public TitleAuthor CreateObject(Author arg0, Title arg1)
	{
		return (TitleAuthor)base.CreateObject(new object[] { arg0.Row["au_id"], arg1.Row["title_id"] } );
	}


	/// <summary>
	/// Find a specified TitleAuthor object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">Author.</param>
	/// <param name="arg1">Title.</param>
	/// <returns> TitleAuthor </returns>
	public TitleAuthor FindObject(Author arg0, Title arg1)
	{
		return (TitleAuthor)base.FindObject(new object[] { arg0.Row["au_id"], arg1.Row["title_id"] } );
	}

	///<summary>
	///Find a specified TitleAuthor object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">Author.</param>
	///<param name="arg1">Title.</param>
	///<returns> TitleAuthor </returns>
	public TitleAuthor FindObjectByPK( System.String arg0 , System.String arg1 )
	{
		return (TitleAuthor) base.FindObject( new object[] {  arg0, arg1 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the TitleAuthor object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> TitleAuthorTemplate </returns>
	public TitleAuthorTemplate GetQueryTemplate()
	{
		return new TitleAuthorTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> TitleAuthor. </returns>
	public override TitleAuthor FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<TitleAuthor> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>TitleAuthor</returns>
    public override TitleAuthor FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<TitleAuthor> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region TitleAuthorEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the TitleAuthor DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class TitleAuthorMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "au_id", "title_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "au_id", "title_id" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "AuId", "TitleId" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { "Title", "Author" };

    private Type concreteObjectType = typeof(TitleAuthor);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(TitleAuthor); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "titleauthor"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(2);
  		infos.Add("Title", new RelationInfo(Factory, typeof(Title), typeof(TitleAuthor), "title_id", "title_id"));
 		infos.Add("Author", new RelationInfo(Factory, typeof(Author), typeof(TitleAuthor), "au_id", "au_id"));
		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of TitleAuthor.</summary>
	/// <remarks>Create new TitleAuthor.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new TitleAuthor(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("au_id", typeof(System.String));
		c = table.Columns.Add("title_id", typeof(System.String));
		table.PrimaryKey = new DataColumn[] { table.Columns["au_id"], table.Columns["title_id"] };
	}
	
	/// <summary>Generates the dataset relationships.</summary>
	/// <remarks>Dataset Relationships.</remarks>
	/// <param name="table">DataTable.</param>
	protected override void WriteRelations(DataTable table)
	{
		DataRelation r;
		
		if(table.DataSet.Relations["titles*titleauthor.title_id"] == null)
		{
			r = table.DataSet.Relations.Add("titles*titleauthor.title_id", 
					table.DataSet.Tables["titles"].Columns["title_id"],
					table.DataSet.Tables["titleauthor"].Columns["title_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.Cascade;
		}
		if(table.DataSet.Relations["authors*titleauthor.au_id"] == null)
		{
			r = table.DataSet.Relations.Add("authors*titleauthor.au_id", 
					table.DataSet.Tables["authors"].Columns["au_id"],
					table.DataSet.Tables["titleauthor"].Columns["au_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.Cascade;
		}
	}
}

#endregion

#region TitleAuthorSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.titleauthor.</para>
/// </remarks>
[Serializable]
public abstract class TitleAuthorSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public TitleAuthorSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="TitleAuthorSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public TitleAuthorSurrogateBase(TitleAuthor entity)
    {
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(TitleAuthor entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
		}
		else
		{
		}
    }
    
    /// <summary>
    /// Property Title - gets or sets the Title object with a one-to-one relationship to this instance.</summary>
    /// <remarks> Property Title - gets or sets the Title object with a one-to-one relationship to this instance.</remarks>
    /// <value> Title. </value>
    public TitleSurrogate Title
    {
    	get {return _title;}
    	set {_title = value;}
    }

	private TitleSurrogate _title;
		
    /// <summary>
    /// Property Author - gets or sets the Author object with a one-to-one relationship to this instance.</summary>
    /// <remarks> Property Author - gets or sets the Author object with a one-to-one relationship to this instance.</remarks>
    /// <value> Author. </value>
    public AuthorSurrogate Author
    {
    	get {return _author;}
    	set {_author = value;}
    }

	private AuthorSurrogate _author;
		

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(TitleAuthorTemplate emptyTemplate)
    {


    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Framework;

#endregion

#region JobBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Job : EntityObject
{
       
	internal Job(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
	}
	
	/// <summary>
	/// Property JobId -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.jobs.job_id.</remarks>
	/// <value> System.Int16. </value>
	public virtual System.Int16? JobId
	{
		get { object v = Row["job_id"]; return (System.Int16?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["job_id"] = value; else Row["job_id"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property Description -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.jobs.job_desc.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Description
	{
		get { return Row["job_desc"] as System.String; }
		set { Row["job_desc"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property MinLevel -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.jobs.min_lvl.</remarks>
	/// <value> System.Int16. </value>
	public virtual System.Int16? MinLevel
	{
		get { object v = Row["min_lvl"]; return (System.Int16?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["min_lvl"] = value; else Row["min_lvl"] = DBNull.Value; }
	}    

	/// <summary>
	/// Property MaxLevel -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.jobs.max_lvl.</remarks>
	/// <value> System.Int16. </value>
	public virtual System.Int16? MaxLevel
	{
		get { object v = Row["max_lvl"]; return (System.Int16?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["max_lvl"] = value; else Row["max_lvl"] = DBNull.Value; }
	}    


	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "JobId") 
			return JobId;
		if(propName == "Description") 
			return Description;
		if(propName == "MinLevel") 
			return MinLevel;
		if(propName == "MaxLevel") 
			return MaxLevel;

		return base.GetProperty(propName);
	}


	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(JobSurrogate surrogate)
	{
		Description = surrogate.Description;
		MinLevel = surrogate.MinLevel;
		MaxLevel = surrogate.MaxLevel;
	}
}

#endregion

#region JobTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Job operations. </remarks>
public class JobTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public JobTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property JobId -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.jobs.job_id.</remarks>
	/// <value> System.Int16. </value>
	public System.Int16 JobId
	{
		get { return (System.Int16)QueryValues["JobId"]; }
		set { QueryValues["JobId"] = value; }
	}

	/// <summary>
	/// Property Description -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.jobs.job_desc.</remarks>
	/// <value> System.String. </value>
	public System.String Description
	{
		get { return (System.String)QueryValues["Description"]; }
		set { QueryValues["Description"] = value; }
	}

	/// <summary>
	/// Property MinLevel -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.jobs.min_lvl.</remarks>
	/// <value> System.Int16. </value>
	public System.Int16 MinLevel
	{
		get { return (System.Int16)QueryValues["MinLevel"]; }
		set { QueryValues["MinLevel"] = value; }
	}

	/// <summary>
	/// Property MaxLevel -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.jobs.max_lvl.</remarks>
	/// <value> System.Int16. </value>
	public System.Int16 MaxLevel
	{
		get { return (System.Int16)QueryValues["MaxLevel"]; }
		set { QueryValues["MaxLevel"] = value; }
	}

               
}

#endregion

#region JobFactory

/// <summary>
/// Factory class for the creation of Job objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class JobFactory : Neo.Framework.GenericObjectFactory<Job>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Job objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public JobFactory(ObjectContext context) : base(context, typeof(Job))
	{
	}

	/// <summary>
	/// Create new Job object.</summary>
	/// <remarks>IdMethod = Native, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 0.</remarks>
	/// <returns> Job </returns>
	public Job CreateObject()
	{
		return (Job)base.CreateObject(null);
	}
	

	/// <summary>
	/// Find a specified Job object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Job </returns>
	public Job FindObject(System.Int16 arg0)
	{
		return (Job)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Job object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">$column.Description.</param>
	///<returns> Job </returns>
	public Job FindObjectByPK( System.Int16 arg0 )
	{
		return (Job) base.FindObject( new object[] {  arg0 } );
	}
	

	///<summary>
	///Find a specified Job object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">$column.Description.</param>
	///<returns> Job </returns>
	public Job FindObjectByPK( System.Int16? arg0 )
	{
		return (Job) base.FindObject( new object[] {  arg0.Value } );
	}
	
	/// <summary>
	/// Return the correct Query Template for the Job object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> JobTemplate </returns>
	public JobTemplate GetQueryTemplate()
	{
		return new JobTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Job. </returns>
	public override Job FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Job> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Job</returns>
    public override Job FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Job> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region JobEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Job DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class JobMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "job_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "job_id", "job_desc", "min_lvl", "max_lvl" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "JobId", "Description", "MinLevel", "MaxLevel" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { };

    private Type concreteObjectType = typeof(Job);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Job); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "jobs"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(0);
 		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new NativePkInitializer();
	}
    
	/// <summary>Creates a new instance of Job.</summary>
	/// <remarks>Create new Job.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Job(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("job_id", typeof(System.Int16));
		c.Unique = true;
		c.AutoIncrement = true; c.AutoIncrementSeed = c.AutoIncrementStep = -1;
		c = table.Columns.Add("job_desc", typeof(System.String));
		c = table.Columns.Add("min_lvl", typeof(System.Int16));
		c = table.Columns.Add("max_lvl", typeof(System.Int16));
		table.PrimaryKey = new DataColumn[] { table.Columns["job_id"] };
	}
	
}

#endregion

#region JobSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.jobs.</para>
/// </remarks>
[Serializable]
public abstract class JobSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public JobSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="JobSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public JobSurrogateBase(Job entity)
    {
		JobId = entity.JobId;
		Description = entity.Description;
		MinLevel = entity.MinLevel;
		MaxLevel = entity.MaxLevel;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Job entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.Description = Description;
			entity.MinLevel = MinLevel;
			entity.MaxLevel = MaxLevel;
		}
		else
		{
			if (_descriptionHasBeenUpdated)
			{
				entity.Description = Description;
			}
			if (_minlevelHasBeenUpdated)
			{
				entity.MinLevel = MinLevel;
			}
			if (_maxlevelHasBeenUpdated)
			{
				entity.MaxLevel = MaxLevel;
			}
		}
    }
    
	/// <summary>
    /// Property JobId -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.jobs.job_id.</remarks>
    /// <value> System.Int16. </value>
    public System.Int16? JobId
    {
    	get {return _jobid;}
		set {_jobid = value;}
    }

	private System.Int16? _jobid;
	
    /// <summary>
    /// Property Description -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.jobs.job_desc.</remarks>
    /// <value> System.String. </value>
    public System.String Description
    {
    	get {return _description;}
    	set {_description = value; _descriptionHasBeenUpdated = true;}
    }

	private System.String _description;
    private bool _descriptionHasBeenUpdated;
	
	/// <summary>
    /// Property MinLevel -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.jobs.min_lvl.</remarks>
    /// <value> System.Int16. </value>
    public System.Int16? MinLevel
    {
    	get {return _minlevel;}
    	set {_minlevel = value; _minlevelHasBeenUpdated = true;}
    }

	private System.Int16? _minlevel;
    private bool _minlevelHasBeenUpdated;
	
	/// <summary>
    /// Property MaxLevel -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.jobs.max_lvl.</remarks>
    /// <value> System.Int16. </value>
    public System.Int16? MaxLevel
    {
    	get {return _maxlevel;}
    	set {_maxlevel = value; _maxlevelHasBeenUpdated = true;}
    }

	private System.Int16? _maxlevel;
    private bool _maxlevelHasBeenUpdated;
	

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(JobTemplate emptyTemplate)
    {
    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Framework;

#endregion

#region StoreBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Store : EntityObject
{
       
	internal Store(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
	}
	
	/// <summary>
	/// Property Name -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.stores.stor_name.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Name
	{
		get { return Row["stor_name"] as System.String; }
		set { Row["stor_name"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Address -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.stores.stor_address.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Address
	{
		get { return Row["stor_address"] as System.String; }
		set { Row["stor_address"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property City -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.stores.city.</remarks>
	/// <value> System.String. </value>
	public virtual System.String City
	{
		get { return Row["city"] as System.String; }
		set { Row["city"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property State -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.stores.state.</remarks>
	/// <value> System.String. </value>
	public virtual System.String State
	{
		get { return Row["state"] as System.String; }
		set { Row["state"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Zip -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.stores.zip.</remarks>
	/// <value> System.String. </value>
	public virtual System.String Zip
	{
		get { return Row["zip"] as System.String; }
		set { Row["zip"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    


	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "Name") 
			return Name;
		if(propName == "Address") 
			return Address;
		if(propName == "City") 
			return City;
		if(propName == "State") 
			return State;
		if(propName == "Zip") 
			return Zip;

		return base.GetProperty(propName);
	}


	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(StoreSurrogate surrogate)
	{
		Name = surrogate.Name;
		Address = surrogate.Address;
		City = surrogate.City;
		State = surrogate.State;
		Zip = surrogate.Zip;
	}
}

#endregion

#region StoreTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Store operations. </remarks>
public class StoreTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public StoreTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property Name -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.stores.stor_name.</remarks>
	/// <value> System.String. </value>
	public System.String Name
	{
		get { return (System.String)QueryValues["Name"]; }
		set { QueryValues["Name"] = value; }
	}

	/// <summary>
	/// Property Address -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.stores.stor_address.</remarks>
	/// <value> System.String. </value>
	public System.String Address
	{
		get { return (System.String)QueryValues["Address"]; }
		set { QueryValues["Address"] = value; }
	}

	/// <summary>
	/// Property City -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.stores.city.</remarks>
	/// <value> System.String. </value>
	public System.String City
	{
		get { return (System.String)QueryValues["City"]; }
		set { QueryValues["City"] = value; }
	}

	/// <summary>
	/// Property State -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.stores.state.</remarks>
	/// <value> System.String. </value>
	public System.String State
	{
		get { return (System.String)QueryValues["State"]; }
		set { QueryValues["State"] = value; }
	}

	/// <summary>
	/// Property Zip -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.stores.zip.</remarks>
	/// <value> System.String. </value>
	public System.String Zip
	{
		get { return (System.String)QueryValues["Zip"]; }
		set { QueryValues["Zip"] = value; }
	}

               
}

#endregion

#region StoreFactory

/// <summary>
/// Factory class for the creation of Store objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class StoreFactory : Neo.Framework.GenericObjectFactory<Store>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Store objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public StoreFactory(ObjectContext context) : base(context, typeof(Store))
	{
	}

	/// <summary>
	/// Create new Store object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 0.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Store </returns>
	public Store CreateObject(System.String arg0)
	{
		return (Store)base.CreateObject(new object[] { arg0 } );
	}
	

	/// <summary>
	/// Find a specified Store object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Store </returns>
	public Store FindObject(System.String arg0)
	{
		return (Store)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Store object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">$column.Description.</param>
	///<returns> Store </returns>
	public Store FindObjectByPK( System.String arg0 )
	{
		return (Store) base.FindObject( new object[] {  arg0 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the Store object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> StoreTemplate </returns>
	public StoreTemplate GetQueryTemplate()
	{
		return new StoreTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Store. </returns>
	public override Store FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Store> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Store</returns>
    public override Store FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Store> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region StoreEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Store DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class StoreMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "stor_id" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "stor_id", "stor_name", "stor_address", "city", "state", "zip" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "StorId", "Name", "Address", "City", "State", "Zip" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { };

    private Type concreteObjectType = typeof(Store);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Store); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "stores"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(0);
 		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of Store.</summary>
	/// <remarks>Create new Store.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Store(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("stor_id", typeof(System.String));
		c.Unique = true;
		c = table.Columns.Add("stor_name", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("stor_address", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("city", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("state", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("zip", typeof(System.String));
		c.AllowDBNull = true;
		table.PrimaryKey = new DataColumn[] { table.Columns["stor_id"] };
	}
	
}

#endregion

#region StoreSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.stores.</para>
/// </remarks>
[Serializable]
public abstract class StoreSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public StoreSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="StoreSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public StoreSurrogateBase(Store entity)
    {
		Name = entity.Name;
		Address = entity.Address;
		City = entity.City;
		State = entity.State;
		Zip = entity.Zip;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Store entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.Name = Name;
			entity.Address = Address;
			entity.City = City;
			entity.State = State;
			entity.Zip = Zip;
		}
		else
		{
			if (_nameHasBeenUpdated)
			{
				entity.Name = Name;
			}
			if (_addressHasBeenUpdated)
			{
				entity.Address = Address;
			}
			if (_cityHasBeenUpdated)
			{
				entity.City = City;
			}
			if (_stateHasBeenUpdated)
			{
				entity.State = State;
			}
			if (_zipHasBeenUpdated)
			{
				entity.Zip = Zip;
			}
		}
    }
    
    /// <summary>
    /// Property Name -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.stores.stor_name.</remarks>
    /// <value> System.String. </value>
    public System.String Name
    {
    	get {return _name;}
    	set {_name = value; _nameHasBeenUpdated = true;}
    }

	private System.String _name;
    private bool _nameHasBeenUpdated;
	
    /// <summary>
    /// Property Address -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.stores.stor_address.</remarks>
    /// <value> System.String. </value>
    public System.String Address
    {
    	get {return _address;}
    	set {_address = value; _addressHasBeenUpdated = true;}
    }

	private System.String _address;
    private bool _addressHasBeenUpdated;
	
    /// <summary>
    /// Property City -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.stores.city.</remarks>
    /// <value> System.String. </value>
    public System.String City
    {
    	get {return _city;}
    	set {_city = value; _cityHasBeenUpdated = true;}
    }

	private System.String _city;
    private bool _cityHasBeenUpdated;
	
    /// <summary>
    /// Property State -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.stores.state.</remarks>
    /// <value> System.String. </value>
    public System.String State
    {
    	get {return _state;}
    	set {_state = value; _stateHasBeenUpdated = true;}
    }

	private System.String _state;
    private bool _stateHasBeenUpdated;
	
    /// <summary>
    /// Property Zip -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.stores.zip.</remarks>
    /// <value> System.String. </value>
    public System.String Zip
    {
    	get {return _zip;}
    	set {_zip = value; _zipHasBeenUpdated = true;}
    }

	private System.String _zip;
    private bool _zipHasBeenUpdated;
	

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(StoreTemplate emptyTemplate)
    {
    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

/* This is a customised template.
 * It overrides some optional methods from EntityMap to allow for testing 
 * with Mocks and fast object creation. Search for #custom# below. 
 */


namespace Pubs4.Model
{

#region Using statements

using System;
using System.Collections;
using System.Data;
using Neo.Core;
using Neo.Core.Util;
using Neo.Framework;

#endregion

#region DiscountBase

/// <summary>
/// Generated table specific Base Class </summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public partial class Discount : EntityObject
{
       
	internal Discount(System.Data.DataRow aRow, Neo.Core.ObjectContext aContext) : base(aRow, aContext)
	{
	}
	
	/// <summary>
	/// Property DiscountType -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.discounts.discounttype.</remarks>
	/// <value> System.String. </value>
	public virtual System.String DiscountType
	{
		get { return Row["discounttype"] as System.String; }
		set { Row["discounttype"] = (value != null) ? (object)value : (object)DBNull.Value; }
	}    

	/// <summary>
	/// Property Value -  $attribute.Description </summary>
	/// <remarks> Database Path: pubs.discounts.discount.</remarks>
	/// <value> System.Decimal. </value>
	public virtual System.Decimal? Value
	{
		get { object v = Row["discount"]; return (System.Decimal?)((v != DBNull.Value) ? v : null); }
		set { if (value.HasValue) Row["discount"] = value; else Row["discount"] = DBNull.Value; }
	}    


	/// <summary>
	/// Property Store - gets or sets the Store object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Property Store - gets or sets the Store object with a one-to-one relationship to this instance.</remarks>
	/// <value> Store. </value>
	public virtual Store Store
	{
		get { object fk = Row["stor_id"]; return (fk == DBNull.Value) ? null : (Store)GetRelatedObject("stores", fk); }
		set { SetRelatedObject(value, "stor_id", "stor_id" ); }
	}

	/// <summary>
	/// Returns the value associated with the propName parameter.</summary>
	/// <remarks> You will need to cast the returned object into its native type upon return.</remarks>
	/// <param name="propName">String property name.</param>
	/// <returns> System.Object. </returns>
	public override object GetProperty(string propName)
	{
		if(propName == "DiscountType") 
			return DiscountType;
		if(propName == "Value") 
			return Value;
		if(propName == "Store") 
			return Store;

		return base.GetProperty(propName);
	}


	
	/// <summary>
    /// Populates the EntityObject from the specified surrogate.
    /// </summary>
    /// <param name="surrogate">The surrogate.</param>
	public void Populate(DiscountSurrogate surrogate)
	{
		Value = surrogate.Value;
	}
}

#endregion

#region DiscountTemplate

/// <summary>
/// Generated table specific Query Template Class </summary>
/// <remarks> A Query Template for Discount operations. </remarks>
public class DiscountTemplate : QueryTemplate
{

	/// <summary>
	/// Constructor </summary>
	/// <remarks> Public Constructor.</remarks>
	/// <param name="anEntityMap">IEntityMap instance.</param>
	public DiscountTemplate(IEntityMap anEntityMap) : base(anEntityMap)
	{
	}
	
	/// <summary>
	/// Property DiscountType -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.discounts.discounttype.</remarks>
	/// <value> System.String. </value>
	public System.String DiscountType
	{
		get { return (System.String)QueryValues["DiscountType"]; }
		set { QueryValues["DiscountType"] = value; }
	}

	/// <summary>
	/// Property Value -  $attributes.Description </summary>
	/// <remarks> Database Path: pubs.discounts.discount.</remarks>
	/// <value> System.Decimal. </value>
	public System.Decimal Value
	{
		get { return (System.Decimal)QueryValues["Value"]; }
		set { QueryValues["Value"] = value; }
	}

	/// <summary>
	/// Property Store - gets or sets the Store object with a one-to-one relationship to this instance.</summary>
	/// <remarks> Gets or sets the Store object.</remarks>
	/// <value> Store. </value>
	public Store Store
	{
		get { return (Store)QueryValues["Store"]; }
		set { QueryValues["Store"] = value; }
	}

               
}

#endregion

#region DiscountFactory

/// <summary>
/// Factory class for the creation of Discount objects.</summary>
/// <remarks> This class is generated by the Neo Framework. Make changes to NeoSupport.vtl.</remarks>
public class DiscountFactory : Neo.Framework.GenericObjectFactory<Discount>
{

	/// <summary>
	/// Constructor requiring an ObjectContext parameter.</summary>
	/// <remarks> Main entry point for the retrieval and creation of new Discount objects.</remarks>
	/// <param name="context">ObjectContext.</param>
	public DiscountFactory(ObjectContext context) : base(context, typeof(Discount))
	{
	}

	/// <summary>
	/// Create new Discount object.</summary>
	/// <remarks>IdMethod = None, PrimaryKeyIsForeignKey = False, RelationshipSetsForColumns = 0.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Discount </returns>
	public Discount CreateObject(System.String arg0)
	{
		return (Discount)base.CreateObject(new object[] { arg0 } );
	}
	

	/// <summary>
	/// Find a specified Discount object.</summary>
	/// <remarks> Requires Primary Key values and/or parent object instances.</remarks>
	/// <param name="arg0">$column.Description.</param>
	/// <returns> Discount </returns>
	public Discount FindObject(System.String arg0)
	{
		return (Discount)base.FindObject(new object[] { arg0 } );
	}

	///<summary>
	///Find a specified Discount object.</summary>
	///<remarks> Requires Primary Key values and/or parent object instances.</remarks>
	///<param name="arg0">$column.Description.</param>
	///<returns> Discount </returns>
	public Discount FindObjectByPK( System.String arg0 )
	{
		return (Discount) base.FindObject( new object[] {  arg0 } );
	}
	

	
	/// <summary>
	/// Return the correct Query Template for the Discount object.</summary>
	/// <remarks> A query template is used for creating SQL like queries, in a more OO fashion.</remarks>
	/// <returns> DiscountTemplate </returns>
	public DiscountTemplate GetQueryTemplate()
	{
		return new DiscountTemplate(EntityMap);
	}
	
	/// <summary>
	/// SQL like query to find and return an object.</summary>
	/// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
	/// <param name="qualifierFormat">String.</param>
	/// <param name="parameters">params object[].</param>
	/// <returns> Discount. </returns>
	public override Discount FindFirst(string qualifierFormat, params object[] parameters)
	{
		ObjectList<Discount> results = FindWithLimit(1, qualifierFormat, parameters);
		return (results.Count > 0) ? results[0] : null;
	}

    /// <summary>
    /// SQL like query to find and return an object.</summary>
    /// <remarks> For example: ...FindFirst("TitleAuthors.(Title = {0} or Title.Publisher = {1})", title, publisher).</remarks>
    /// <param name="q">The Qualifier.</param>
    /// <returns>Discount</returns>
    public override Discount FindFirst(Qualifier q)
    {
        FetchSpecification f = new FetchSpecification(EntityMap, q, 1);
		ObjectList<Discount> result = Find(f);
		return result.Count > 0 ? result[0]: null;
    }
}

#endregion

#region DiscountEntityMap

//  -------- Entity Map -----------------------------------------------------
/// <summary>Creates the in memory version of the dataset for the Discount DOM.</summary>
/// <remarks>Generated by Neo Framework.</remarks>
internal class DiscountMap : EntityMap
{
	  /// <summary>Array of Primary Key column names.</summary>
	  /// <remarks>Primary Key columns.</remarks>
    private static readonly string[] pkcolumns = { "discounttype" };
    /// <summary>Array of Database column names.</summary>
	  /// <remarks>Database column names.</remarks>
    private static readonly string[] columns = { "discounttype", "stor_id", "discount" };
    /// <summary>Array of DOM object properties.</summary>
	  /// <remarks>DOM object properties.</remarks>
    private static readonly string[] attributes = { "DiscountType", "StorId", "Value" };
    /// <summary>Array of Related Object names.</summary>
	  /// <remarks>Related Object names.</remarks>
    private static readonly string[] relations = { "Store" };

    private Type concreteObjectType = typeof(Discount);

	  /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ObjectType
    {
        get { return typeof(Discount); }
    }
    
    /// <summary>Property ObjectType.</summary>
	  /// <remarks>Returns the DOM's Type.</remarks>
	  /// <value>System.Type.</value>
    public override System.Type ConcreteObjectType
    {
        get { return concreteObjectType; }										 /* #custom# overridden */
        set { concreteObjectType = value; Factory.AddCustomType(value, this); }  /* #custom# overridden */
    }
    
    /// <summary>Property TableName.</summary>
	  /// <remarks>Returns database table name.</remarks>
	  /// <value>string.</value>
    public override string TableName
    {
        get { return "discounts"; }
    }
    
    /// <summary>Property PrimaryKeyColumns.</summary>
	/// <remarks>Array of Primary Key column names.</remarks>
	/// <value>string[].</value>
    public override string[] PrimaryKeyColumns
    {
        get { return pkcolumns; }
    }

	/// <summary>Property Columns.</summary>
	/// <remarks>Array of Database column names.</remarks>
	/// <value>string[].</value>
    public override string[] Columns
    {
        get { return columns; }
    }

	/// <summary>Property Attributes.</summary>
	/// <remarks>Array of DOM object properties.</remarks>
	/// <value>string[].</value>
    public override string[] Attributes
    {
        get { return attributes; }
    }

    /// <summary>Property Relations.</summary>
	/// <remarks>Array of Related Object names.</remarks>
	/// <value>string[].</value>
    public override string[] Relations
    {
        get { return relations; }
    }

	/// <summary>Generates a Hashtable, keyed by Object Name, or information regarding related objects.</summary>
	/// <remarks>Related Objects.</remarks>
	/// <returns>IDictionary.</returns>
  	protected override IDictionary GetRelationInfos()
    {
    	IDictionary infos = new Hashtable(1);
  		infos.Add("Store", new RelationInfo(Factory, typeof(Store), typeof(Discount), "stor_id", "stor_id"));
		return infos;    	
    }
    
	/// <summary>Based upon the model specified Id Method, returns the proper PkInitializer.</summary>
	/// <remarks>The object used to create a new PK value.</remarks>
	/// <returns>IPkInitializer.</returns>
	public override IPkInitializer GetPkInitializer()
	{
		return new UserPkInitializer();
	}
    
	/// <summary>Creates a new instance of Discount.</summary>
	/// <remarks>Create new Discount.</remarks>
	/// <param name="row">DataRow.</param>
	/// <param name="context">ObjectContext.</param>
	/// <returns>IEntityObject.</returns>
    public override IEntityObject CreateInstance(DataRow row, ObjectContext context) /* #custom# overridden */
    {
		if(ConcreteObjectType != ObjectType)
			return base.CreateInstance(row, context);
		return new Discount(row, context);
	}
    
    /// <summary>Generates the in memory dataset.</summary>
	/// <remarks>Called by the Factory object.</remarks>
	/// <param name="table">DataTable.</param>
    protected override void WriteBasicSchema(DataTable table)
    {
		DataColumn		c;
		
		c = table.Columns.Add("discounttype", typeof(System.String));
		c.Unique = true;
		c = table.Columns.Add("stor_id", typeof(System.String));
		c.AllowDBNull = true;
		c = table.Columns.Add("discount", typeof(System.Decimal));
		c.AllowDBNull = true;
		table.PrimaryKey = new DataColumn[] { table.Columns["discounttype"] };
	}
	
	/// <summary>Generates the dataset relationships.</summary>
	/// <remarks>Dataset Relationships.</remarks>
	/// <param name="table">DataTable.</param>
	protected override void WriteRelations(DataTable table)
	{
		DataRelation r;
		
		if(table.DataSet.Relations["stores*discounts.stor_id"] == null)
		{
			r = table.DataSet.Relations.Add("stores*discounts.stor_id", 
					table.DataSet.Tables["stores"].Columns["stor_id"],
					table.DataSet.Tables["discounts"].Columns["stor_id"]);
			r.ChildKeyConstraint.UpdateRule = Rule.Cascade;
			r.ChildKeyConstraint.DeleteRule = Rule.None;
		}
	}
}

#endregion

#region DiscountSurrogateBase

/// <summary>Represents an entity object disconnected from the database.</summary>
/// <remarks>
///   <para>Database Path: pubs.discounts.</para>
/// </remarks>
[Serializable]
public abstract class DiscountSurrogateBase : EntityObjectSurrogate
{
    /// <summary>Default constructor.</summary>
    public DiscountSurrogateBase()
    {
    }
    
    /// <summary>
    /// Initializes a new instance of the <see cref="DiscountSurrogateBase"/> class.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public DiscountSurrogateBase(Discount entity)
    {
		DiscountType = entity.DiscountType;
		Value = entity.Value;
    }
    
    /// <summary>
    /// Updates the entity with the values contained within the surrogate.
    /// </summary>
    /// <param name="entity">The entity.</param>
    public void BindObjectInstance(Discount entity)
    {
		if (entity.Row.RowState == DataRowState.Added)
        {
			entity.Value = Value;
		}
		else
		{
			if (_valueHasBeenUpdated)
			{
				entity.Value = Value;
			}
		}
    }
    
    /// <summary>
    /// Property DiscountType -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.discounts.discounttype.</remarks>
    /// <value> System.String. </value>
    public System.String DiscountType
    {
    	get {return _discounttype;}
		set {_discounttype = value;}
    }

	private System.String _discounttype;
	
	/// <summary>
    /// Property Value -  $attribute.Description </summary>
    /// <remarks> Database Path: pubs.discounts.discount.</remarks>
    /// <value> System.Decimal. </value>
    public System.Decimal? Value
    {
    	get {return _value;}
    	set {_value = value; _valueHasBeenUpdated = true;}
    }

	private System.Decimal? _value;
    private bool _valueHasBeenUpdated;
	
    /// <summary>
    /// Property Store - gets or sets the Store object with a one-to-one relationship to this instance.</summary>
    /// <remarks> Property Store - gets or sets the Store object with a one-to-one relationship to this instance.</remarks>
    /// <value> Store. </value>
    public StoreSurrogate Store
    {
    	get {return _store;}
    	set {_store = value;}
    }

	private StoreSurrogate _store;
		

    /// <summary>
    /// Binds the surrogate values to the search template.
    /// </summary>
    /// <param name="emptyTemplate">The empty template.</param>
	public void BindToSearchTemplate(DiscountTemplate emptyTemplate)
    {

    }
    
	/// <summary>
	/// Determines whether this instance is valid.
	/// </summary>
	/// <returns>
	///	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
	/// </returns>
    public abstract bool IsValid();

	/// <summary>
	/// Gets the validation message.
	/// </summary>
	/// <value>The validation message.</value>
    public abstract String ValidationMessage{get;}

}
#endregion

}

